package com.laoxu.test.sqlitedemo.controller;

import com.laoxu.test.sqlitedemo.model.User;
import com.laoxu.test.sqlitedemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author laoxu
 * @Date 2019/11/5 23:13
 **/
@RestController
@RequestMapping("/api/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/get/{id}")
    public User get(@PathVariable Integer id){
        return userService.getOne(id);
    }

    @GetMapping("/getAll")
    public List<User> getAll(){
        return userService.getAll();
    }

    @PostMapping("/remove")
    public Boolean remove(@RequestParam Integer id){
        return userService.remove(id);
    }

    @PostMapping("/add")
    public Boolean add(@RequestBody User user){
        return userService.add(user);
    }

    @PostMapping("/modify")
    public Boolean update(@RequestBody User user){
        return userService.modify(user);
    }

}
